package sjtu.pirate.httpclient;

import java.io.IOException;
import java.net.URISyntaxException;
import org.apache.http.client.ClientProtocolException;
import sjtu.pirate.format.Content;
import sjtu.pirate.format.Form;
/**
 * @author wilbur.ma@qq.com
 * @date 2011.05.26
 * Client class which handles http communication.
 */
public class HTTPClient{
	private PirateClient client;
	
	public HTTPClient() {
		client = new PirateClient();
	}
	
	public HTTPClient(String encoding) {
		client = new PirateClient(encoding);
	}
	
	public int sendRequest(Content content) {
		for (Form f : content.getFormList()) {
			try {
				client.sendRequest(f);
			} catch (URISyntaxException e) {
				e.printStackTrace();
			} catch (ClientProtocolException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			} finally {
			}
		}
		return 0;
	}
}